# -*- coding: utf-8 -*-
#Given /^the following posts:$/ do |posts|
Given /^次のポストがある$/ do |posts|
  Post.create!(posts.hashes)
end

#When /^I delete the (\d+)(?:st|nd|rd|th) post$/ do |pos|
When /^(\d+) ?番目のポストを削除/ do |pos|
  visit posts_url
  within("table > tr:nth-child(#{pos.to_i+1})") do
    click_link "削除"
  end
end

When /^(\d+) ?番目のポストを編集/ do |pos|
  visit posts_url
  within("table > tr:nth-child(#{pos.to_i+1})") do
    click_link "編集"
  end
end

#Then /^I should see the following posts:$/ do |expected_posts_table|
Then /^次のポストが表示されること$/ do |expected_posts_table|
  expected_posts_table.diff!(table_at('table').to_a)
end
